package com.example.demofdfs.test.obj;

import java.util.Queue;

public class Consumer<E> implements Runnable {

	private Queue<E> queue;
	
	public Consumer(Queue<E> queue) {
		this.queue = queue;
	}
	
	public E get() {
		E e = null;
//		synchronized (queue) {
//			if (queue.isEmpty()) {
//					try {
//						queue.wait();
//					} catch (InterruptedException e1) {
//						e1.printStackTrace();
//					}
//			} else {
//				e = queue.poll();
//				queue.notifyAll();
//			}
//		}
		e = queue.poll();
		return e;
	}

	@Override
	public void run() {
		while(true) {
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println(get());
		}
	}
}
